package routers

import (
	"../middleware"
	"../pkg/settings"
	"../routers/api"
	"../routers/api/v1"
	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {

	r := gin.New()
	//log  可以替换
	r.Use(gin.Logger())
	r.Use(gin.Recovery())
	gin.SetMode(settings.ServerSetting.RunMode)
	r.POST("/auth", api.Login)
	apiv1 := r.Group("/api/v1")
	apiv1.Use(middleware.JWT())
	{
		apiv1.GET("/test", v1.Demo)
	}

	apiV2 := r.Group("/api/v2")
	{
		apiV2.GET("/a1", v1.A1)
		apiV2.GET("/cron", v1.Cron)
	}
	return r

}
